//
//  CodingTest.m
//  ArchiveDemo
//
//  Created by shk on 14/12/8.
//  Copyright (c) 2014年 com.shk. All rights reserved.
//

#import "CodingTest.h"
#import "UserInfo.h"

@implementation CodingTest{
    NSString *_path;
}

- (void) archiveCodingObject{
    UserInfo *userInfo = [[UserInfo alloc] init];
    userInfo.name = @"shk";
    userInfo.email = @"songhaikang@163.com";
    userInfo.password = @"123";
    userInfo.age = 26;
    _path = [NSHomeDirectory() stringByAppendingPathComponent:@"temp/oc-demo-archive-coding-object.array"];
    BOOL success = [NSKeyedArchiver archiveRootObject:userInfo toFile:_path];
    if(success){
        NSLog(@" archive success !");
    }
}


- (void)unArchiveCodingObject{
    _path = [NSHomeDirectory() stringByAppendingPathComponent:@"temp/oc-demo-archive-coding-object.array"];
    UserInfo *userInfo = [NSKeyedUnarchiver unarchiveObjectWithFile:_path];
    NSLog(@"%@", userInfo);//调用UserInfo类的description函数
    
    
}



@end
